package cn.edu.sdu.sduhour.controller;

import cn.edu.sdu.sduhour.entity.Tips;
import cn.edu.sdu.sduhour.mapper.TipsMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

//127.0.0.1:8080/tips/all
@RestController
@RequestMapping("/tips")
public class TipsController {
    @Resource
    TipsMapper tipsMapper;

    //获取所有提示
    /*传入：null*/
    @GetMapping("/all")
    public List<Tips> findAll() {
        return tipsMapper.findAll();
    }

    //获取一条提示
    /*传入：int id;*/
    @PostMapping("/one")
    public List<Tips> findOne(@RequestBody Tips tips) {
        return tipsMapper.findOne(tips);
    }

    //插入一条提示
    /*传入：String tip;*/
    @PostMapping("/add")
    public String addOne(@RequestBody Tips tips) {
        tipsMapper.addOne(tips);
        return "success";
    }

    //删除一条提示
    /*传入：int id;*/
    @DeleteMapping("/del")
    public String delOne(@RequestBody Tips tips) {
        tipsMapper.delOne(tips);
        return "success";
    }
}
